<include file="Public:header" />
<form name="myform" id="myform" method="POST" action="__ACTION__" >
  <input name="id" id="user_id" type="hidden" value="{$info.id}" />
  <fieldset>
    <legend>管理员信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th width="100">用户名：</th>
          <td id="userInput">
          	<empty name="info.username">
            	<input name="username" id="username" type="text" class="input-text" size="20" value=""  />
                <span class="onShow hidden"></span><span class="orange">设定后不能再修改。</span>
            <else />
            	{$info.username}
            </empty>
          </td>
        </tr>
        <tr>
          <th>密码：</th>
          <td>
          	<input name="password" type="password" id="password" class="input-text" size="20" >
            <span class="onShow"></span>
            <notempty name="info['id']"><span class="orange">留空为不修改！</span></notempty>
            </td>
        </tr>
        <tr>
          <th>管理员组：</th>
          <td>
          	<select name="role_id" id="role_id">
         	    <option value="0" selected="selected">所属分组</option>
              <volist name=":get_role_list()" id="vo">
                <option value="{$vo.id}" {:selected($vo['id'],$info['role_id'])} />{$vo.name}</option>
              </volist>
            </select>
          </td>
        </tr>
        <eq name="admin" value="1">
        <tr >
          <th>特殊权限：</th>
          <td style="text-align:left">
          	<input type="checkbox" name="admin" value="1" <eq name="info['admin']" value="1"> checked="checked" </eq> />
            <span class="orange">（允许查看所有电话记录）</span>
		  </td>
        </tr>
        </eq>
        <tr class="last">
          <th>启用状态：</th>
          <td style="text-align:left">
          	<input type="radio" name="status" value="1" checked="checked" /> 启用
          	<input type="radio" name="status" value="0" <eq name="info.status" value="0"> checked </eq> />停用
		  </td>
        </tr>

      </tbody>
    </table>
  </fieldset>
  <fieldset {$hide}>
    <legend>个人信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th width="100">昵称：</th>
          <td><input name="data[nickname]" id="nickname" class="input-text" type="text" size="20" value="{$info.nickname}" />
            </td>
        </tr>
        <tr>
          <th>电话：</th>
          <td><input type="text" class="input-text hideborder" name="data[phone]" id="phone" size="20"  value="{$info.phone}" />
            </td>
        </tr>
        <tr class="last">
          <th>备注：</th>
          <td><textarea name="data[remark]" id="remark" class="input-text" cols="60" rows="4" />{$info.remark}</textarea></td>
        </tr>
      </tbody>
    </table>
  </fieldset>
  <input type="submit" value="提交" class="dialog" id="dosubmit">
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(e) {
	var role_id = "{$info.role_id}";
	$("#role_id").val(role_id);

    $('#myform').ajaxForm({
			beforeSubmit:  checkForm,
			success:       complete,
			dataType: 'json'
	});

	function checkForm(){
		var user_id = $("#user_id").val();
		var role_id = $("#role_id").val();
		var username  = $("#username").val();
		var password  = $("#password").val();
		if( user_id=='' && username.length<2 ){
			checkInfo('username','姓名不能为空！');
			$('#username').focus();
			return false;
		}
		if( user_id=='' && password.length<6 ){
			//art.dialog({id:'TNCICC',content: '密码不能小于6个字符！',time: 2,icon:'warning'});
			checkInfo('password','密码不能小于6个字符！');
			$('#password').focus();
			return false;
		}

		if(role_id==0){
			art.dialog({id:'TNCICC',content: '请选择分组！',time: 2,icon:'warning'});
			return false;
		}
		return true;
	}
	var origin = $.artDialog.open.origin;
	function complete(data){
		if(data.status==1){
			art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'succeed'});
			setTimeout(function(){origin.location.reload();closeWin()},1500);
		}else{
			art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'warning'});
		}

	}

});

</script>